<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/friend.php');
require_once ('../lib/init.php');
$me = getOneself();

if(!$me){
    print $login_button;
    exit();
}else{
    print $logout_button;
}

/*
 * TEST CODE START
 */
try{
    /*
     * comment query
     */
//    $result = $facebook->api(array('method' => 'fql.query',
//        'query' => "SELECT post_id, fromid, text FROM comment 
//        WHERE fromid != me()
//        	AND (object_id IN (SELECT link_id FROM link WHERE owner = me()) 
//        	OR object_id IN (SELECT note_id FROM note WHERE uid = me())
//        	OR object_id IN (SELECT status_id FROM status WHERE uid = me()))"
//    ));

    /*
     * Message query
     */
//    $result = $facebook->api(array(
//        'method' => 'fql.query',
//        'query' => "SELECT message_id, body FROM message WHERE thread_id IN (
//            			SELECT thread_id FROM thread WHERE folder_id IN (
//            				SELECT folder_id FROM mailbox_folder WHERE viewer_id = me()
//            			)
//            		) AND author_id != me()"
//    ));
    
    /*
     * like query
     * it's no problem when friends like my things
     * but when I like their things it is a problem
     * A fql query that's supposed to return friends doesn't return data but null
     */
//    $result = $facebook->api(array(
//        'method' => 'fql.query',
//        'query' => "SELECT user_id, object_id FROM like 
//        				WHERE (
//            				object_id IN (
//            					SELECT link_id FROM link WHERE owner = me()
//            				) 
//                        	OR object_id IN (
//                        		SELECT note_id FROM note WHERE uid = me()
//                        	)
//                        	OR object_id IN (
//                        		SELECT status_id FROM status WHERE uid = me()
//                        	)
//                        ) AND user_id != me()
//					"
//    ));

//    $result = $facebook->api(array(
//        'method' => 'fql.query',
//        'query' => "SELECT user_id, object_id FROM like 
//    				WHERE object_id IN (
//        					SELECT link_id FROM link WHERE owner IN (
//        						SELECT uid2 FROM friend WHERE uid1 = me()
//        					)
//        			) AND user_id = me()"
//    ));

    print_r($result);
    

}catch(FacebookApiException $e){
    print($e);
}
?>